<template>
  <div>
    <image></image>
    <el-dropdown>
      <span class="el-dropdown-link"
        >{{ username }} <i class="el-icon-arrow-down el-icon--right"></i
      ></span>
      <el-dropdown-menu>
        <el-dropdown-item>退出</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
// import { view } from "../../api/client";
import router from "../../router";
export default {
  setup() {
    let username = sessionStorage.getItem("username");
    let userimg = sessionStorage.getItem("img");
    // 获取用户信息api
    // if (!username && !userimg) {
    // let datalist = { token: sessionStorage.getItem("Autorization") };
    // view(datalist).then((res) => {
    //   if (res?.data) {
    //     // sessionStorage保存
    //     sessionStorage.setItem("username", JSON.stringify(res.data?.name));
    //     sessionStorage.setItem("img", JSON.stringify(res.data?.img));
    //   }
    // });
    // }

    // 退出登录
    function exit() {
      sessionStorage.removeItem("username");
      sessionStorage.removeItem("img");
      sessionStorage.removeItem("Autorization");
      router.push("/login");
    }

    return { username, userimg, exit };
  },
};
</script>